import Tools from "./Tools";
import Consts from "./Consts";
import Format from "./Format";
import { $alert, $confirm } from "./MessageBox";
import _ from "lodash";


const Filters = {
  toDate: (date, type) => {
    return Format.toDate(date, type);
  },
  date: (date, type) => {
    return Format.date(date, type);
  },
  numberMoney: (number, type) => {
    return Format.numberMoney(number, type);
  },
  numberAmount: (number, type) => {
    return Format.numberAmount(number, type);
  },
  numberPercent: number => {
    return Format.numberPercent(number);
  },
  numberScience: num => {
    return Format.numberScience(num);
  },
  strIsNull: str => {
    return Format.strIsNull(str);
  }};

class AuthClazz {
  constructor() {
    this.keep = null;
  }

  getAuths() {
    return this.keep;
  }

  hasAuth(authId) {
    // return _.indexOf(this.keep, authId) > -1;
    return true;
  }
}
//权限模块
let Auth = new AuthClazz();





const Utils = {
  Consts,
  Tools,
  Format,
  Auth,
  $alert,
  $confirm
}

export default {
  install: Vue => {
    Vue.prototype.Utils = Utils;
    _.forEach(Filters, (v, k) => {
      Vue.filter(k, v);
    });
  },
  ...Utils
};


export {
  Consts,
  Tools,
  Format,
  Auth,
  $alert,
  $confirm
}
